package com.zr.gdms.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.gdms.dao.UserDao;
import com.zr.gdms.model.Student;
import com.zr.gdms.model.User;
import com.zr.gdms.service.StudentService;
import com.zr.gdms.serviceimpl.StudentServiceimpl;

import net.sf.json.JSONObject;

//查询所有学生信息
public class StudentController extends HttpServlet {
	StudentService ss=new StudentServiceimpl();
			@Override
			protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
				// TODO Auto-generated method stub
				doPost(req, resp);
			}
		@Override
		protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub			   
			req.setCharacterEncoding("utf8");
			resp.setCharacterEncoding("utf8");
			HttpSession session=req.getSession();			
			PrintWriter pt=resp.getWriter();
			int page=Integer.parseInt(req.getParameter("page"));
			int rows=Integer.parseInt(req.getParameter("rows"));			
			JSONObject j=ss.getStudents(page, rows);	
			pt.write(j.toString());
			pt.flush();
			pt.close();
		}
}
